package com.gy.controller;

import com.gy.pojo.LeiXing;
import com.gy.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class LeiXingController {
    @Autowired
    BaoXiuService baoXiuService;
    @Autowired
    LeiXingService leiXingService;
    @Autowired
    NoticeService noticeService;
    @Autowired
    UserService userService;
    @Autowired
    QuYuService quYuService;



    //查看故障类型
    @RequestMapping("/worker/selectleixing")
    public String selectLX(Model model){
        List<LeiXing> leiXings = leiXingService.selectLX();
        model.addAttribute("LX",leiXings);


        return "worker/leixing";
    }
    //来到增加故障类型页面  传入最大Lid
    @RequestMapping("/worker/addLeixing")
    public String addLX(){

        return "worker/addleixing";
    }

    //增加故障类型
    @RequestMapping("/worker/addlx")
    public String addleixing(String Lname){
        int Lid= leiXingService.selectMax()+1;
        leiXingService.addLX(new LeiXing(Lid,Lname));


        return "redirect:/worker/selectleixing";
    }


    //删除故障类型
    @RequestMapping("/worker/deletelx/{Lname}")
    public String deleteLX(@PathVariable("Lname") String Lname){

        leiXingService.deleteLXByName(Lname);

        return "redirect:/worker/selectleixing";
    }

/*    //修改类型名
    @RequestMapping("/worker/updatelx/{Lname}")
    public String updalx(@PathVariable("Lname") String Lname){
        leiXingService.
        return "";
    }*/


}
